Skip to content

refactor(knowledge-base): separate frontend sources from the installable runtime - #2967

Open
Lumea-art wants to merge 5 commits into
oceanbase:masterfrom
Lumea-art:feat/knowledge-base-source-layout
Open

Lumea-art wants to merge 5 commits into
oceanbase:masterfrom
Lumea-art:feat/knowledge-base-source-layout

Conversation

@Lumea-art

@Lumea-art Lumea-art commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2966.

Change

The knowledge-base plugin now has one source root:

plugins/knowledge-base/
  README.md
  frontend/          React/TypeScript sources, lockfile, build tooling
  runtime/           plugin.py, pc_knowledge_base/, ui/
  • frontend/build.mjs writes checked-in assets to runtime/ui/, so editing unbuilt sources or installing node_modules never changes the installable tree.
  • Installing means copying the contents of runtime/ into <plugins-dir>/knowledge-base. Copying runtime itself would change the plugin identity; the plugin-development and knowledge-base guides now state this transition explicitly.
  • Staging tests assert the installed directory has plugin.py but no runtime/, frontend/ or node_modules/, then start a real Server and exercise the Dashboard entry/assets and plugin API.

Repository updates

  • npm cache glob, npm ci/npm run build prefixes, generated-asset drift check and ty path in the knowledge-base CI job.
  • pyproject.toml type-check paths, .licenserc.yaml, .github/ci-paths.toml.
  • Evaluation entry points and all knowledge-base unit/e2e imports now point at runtime/.
  • English/Chinese plugin-development guides and knowledge-base guides document the source/runtime convention and staged install.

Validation

  • pytest tests/knowledge_base tests/test_ci_changes.py → 227 passed, 14 skipped.
  • python -m evaluation.knowledge_base dry-run (Python 3.12.14, knowledge-base extras) → 11 fixtures verified.
  • npm ci + npm run build from plugins/knowledge-base/frontend produced no drift in runtime/ui.
  • Plugin ty check only reports missing optional opendal/rapidocr/fastembed packages locally; CI installs the knowledge-base extras. The staged real-Server e2e runs in the knowledge-base CI job.

AI assistance

Authored with AI assistance and reviewed by the contributor before submission.

…ble runtime

Give the first-party knowledge-base plugin one source root. React sources,
lockfile and build tooling move to plugins/knowledge-base/frontend/, while the
installable plugin.py, Python package and built Dashboard assets move to
plugins/knowledge-base/runtime/. The frontend build writes runtime/ui/, so
installing frontend dependencies or editing unbuilt sources leaves the
installable directory untouched.

Staging copies the contents of runtime/ into <plugins-dir>/knowledge-base; tests
assert the installed directory has no runtime/, frontend/ or node_modules. Update
npm caching, build and drift checks, type-check paths, licence path, CI change
detection, evaluation imports and e2e staging. Document the convention and
transition in the English and Chinese plugin development guides and the
knowledge-base install guide.
@hidb4ai hidb4ai added the module:knowledge-base Primary module: knowledge base import, processing and retrieval label Dec 2, 2026

@Zxf-xufeng Zxf-xufeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the four review comments before merge. I reproduced the two evaluation regressions on this commit with CPython 3.12.14 and the locked dependencies. Both checks pass on the PR base. Please request another review once the fixes and documentation updates are ready.

Comment thread evaluation/knowledge_base/__main__.py Resolved
Comment thread evaluation/knowledge_base/legacy.py Resolved
Comment thread docs/en/docs/develop/plugins.md Resolved
Comment thread plugins/knowledge-base/README.md Resolved
Refresh scorer_sha256 in the evaluator manifest after the evaluator import path
changed; the Python 3.12 dry run passes all 11 fixtures again. Resolve the
legacy export's plugin directory from the supplied checkout's layout, accepting
both the historical plugin root and the new runtime/ root, so the e6e36a4
checkout still imports pc_knowledge_base. Name plugins/<plugin-name>/ explicitly
in both plugin-development guides and add plugins/README.md as the first-party
plugin index.
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Addressed the four review comments in f061101:

  • P1 manifest: refreshed scorer_sha256 after the evaluator import path change. uv run --python 3.12.14 --no-default-groups --extra knowledge-base --extra knowledge-base-formats python -m evaluation.knowledge_base dry-run now verifies all 11 fixtures and the toolchain.
  • P2 historical export: legacy.py resolves pc_knowledge_base from either plugins/knowledge-base/runtime/ or the historical plugins/knowledge-base/ layout, so the documented e6e36a43 checkout still imports. I checked the historical checkout’s import directory resolution locally.
  • P3 docs: both plugin-development guides now name plugins/<plugin-name>/ explicitly and distinguish it from the deployer’s configured installation directory.
  • README: added plugins/README.md as the first-party plugin index with links to the knowledge-base plugin and both plugin-writing guides.

@Zxf-xufeng Zxf-xufeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the four previous requests at f0611013b. The evaluation dry run passes all 11 fixtures on the pinned toolchain, the six historical samples match the recorded baseline byte for byte, both guides specify the repository path, and GitHub now lists plugins/ separately. One correction remains in the new directory index: please specify the named installation subdirectory in the line below.

Comment thread plugins/README.md Resolved
@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Knowledge base. @Zxf-xufeng, please coordinate follow-up. Knowledge base: @Zxf-xufeng @Alanxtl. Please coordinate the review of the affected changes.

@Lumea-art
Lumea-art requested a review from Alanxtl as a code owner December 3, 2026 05:38
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Fixed in f5ab2c6: plugins/README.md now says the runtime/ contents are copied into
<configured-plugins-dir>/<plugin-name>/ so plugin.py sits directly inside the named directory, with
<configured-plugins-dir>/knowledge-base/ as the knowledge-base example. This matches the plugin-specific README and
the verified named staging path.

@Lumea-art

Copy link
Copy Markdown
Contributor Author

Also aligned the remaining #2966 acceptance details in 42cc8b8:

  • plugins/knowledge-base/README.md now has explicit npm ci/npm run build and named-directory cp -R runtime/. commands.
  • Both plugin-development guides state that the layout applies to first-party Server plugins; host integrations and the core Dashboard keep their own packaging conventions.
  • plugins/README.md now names <configured-plugins-dir>/<plugin-name>/ (knowledge-base example included), matching the verified staging path.

@Zxf-xufeng Zxf-xufeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All five previous review threads are addressed, including the install destination in the top-level index. With the plugin directory set, I verified the documented staging layout against a real Server. One issue remains in the newly added shell example when the variable is unset.

Non-blocking path cleanup: the current merge result still lists frontend/knowledge-base/ in MAINTAINERS.md and .github/CODEOWNERS, and the CI selector test uses plugins/knowledge-base/pc_knowledge_base/content.py. The existing plugins/knowledge-base/ ownership rule and CI glob cover the moved code. Removing the obsolete references and using real runtime/frontend paths in the test would keep those examples accurate.

Copying the `runtime` directory itself would give the plugin the wrong identity:

```bash
mkdir -p "$POWERCONTEXT_SERVER_PLUGINS_DIR/knowledge-base"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Make the installation destination explicit before creating it. A Server configured through its service environment can have a plugin directory even when the shell running these commands has no POWERCONTEXT_SERVER_PLUGINS_DIR. In that shell the example expands to mkdir -p /knowledge-base and copies the runtime there. It fails for a typical unprivileged user or installs outside the configured directory if the account can write to /. Please show how to set the variable to the actual Server plugin directory, or guard the snippet before either filesystem operation with : "${POWERCONTEXT_SERVER_PLUGINS_DIR:?Set this to the Server plugin directory}". The named knowledge-base/ destination itself is correct.

@Zxf-xufeng Zxf-xufeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 42cc8b8728d03dec5924680e230cf9bf0552dc8d. One note on keeping plugins/README.md scoped as a directory index rather than encoding plugin-specific layout and installation steps.

Comment thread plugins/README.md
Comment on lines +3 to +9
Each subdirectory is the source root of one first-party PowerContext Server plugin. A plugin with a separately built
Dashboard keeps its frontend sources under `frontend/` and the installable files under `runtime/`; only the contents of
`runtime/` are copied into `<configured-plugins-dir>/<plugin-name>/`, so `plugin.py` is directly inside the named
directory. For example, the knowledge-base runtime is installed at `<configured-plugins-dir>/knowledge-base/`.

- [Knowledge-base plugin](knowledge-base/README.md)
- [Write a plugin](../docs/en/docs/develop/plugins.md) · [编写插件](../docs/zh/docs/develop/plugins.md)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep plugins/README.md scoped as a directory index instead of describing frontend//runtime/ layout details or plugin-specific installation paths here. Different first-party plugins can have different subdirectory layouts (for example, Python-only plugins without frontend/ or runtime/) and different installation steps; those details belong in each plugin's own README and the plugin development guides.

Suggested change
Each subdirectory is the source root of one first-party PowerContext Server plugin. A plugin with a separately built
Dashboard keeps its frontend sources under `frontend/` and the installable files under `runtime/`; only the contents of
`runtime/` are copied into `<configured-plugins-dir>/<plugin-name>/`, so `plugin.py` is directly inside the named
directory. For example, the knowledge-base runtime is installed at `<configured-plugins-dir>/knowledge-base/`.
- [Knowledge-base plugin](knowledge-base/README.md)
- [Write a plugin](../docs/en/docs/develop/plugins.md) · [编写插件](../docs/zh/docs/develop/plugins.md)
Each subdirectory holds the source of one first-party PowerContext Server plugin. Follow each plugin's README for its
layout, build, and installation steps, and see the plugin development guide for general conventions.
## Plugins
- [Knowledge-base](knowledge-base/README.md)
## Guides
- [Write a plugin](../docs/en/docs/develop/plugins.md) · [编写插件](../docs/zh/docs/develop/plugins.md)

cp -R plugins/knowledge-base/runtime/. "$POWERCONTEXT_SERVER_PLUGINS_DIR/knowledge-base/"
```

The Dashboard is built from `frontend/` and the result is checked in under `runtime/ui/`:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the optional Dashboard build before the install step and state that both examples run from the repository root. Someone installing a checkout can use the assets already committed under runtime/ui/. Someone who edited the frontend needs to rebuild before copying runtime/. Following the examples in their current order installs the old assets and leaves the rebuilt files in the checkout.

@jasper-yl

Copy link
Copy Markdown
Contributor

Before this merges, I've raised a question about the layout convention in #2966: a framework-side .pluginignore as an alternative, and, if this layout stays, the runtime/ name and a symlink-based development workflow. It would be good to settle that first, since the convention is also written into the plugin-writing guide here. It is not a comment on the quality of the changes in this PR.

合并之前,我在 #2966 提了一个关于布局约定的问题:框架侧 .pluginignore 作为替代方案;若保留本布局,则涉及 runtime/ 的命名和基于符号链接的开发方式。由于约定在这里也写进了插件编写指南,建议先把那边定下来。这不是对本 PR 改动质量的意见。

@Zxf-xufeng

Copy link
Copy Markdown
Member

@Lumea-art Thanks again for all the careful work on this PR and getting the CI checks green.

Before we merge, @jasper-yl raised an alternative in #2966—handling this in the framework via .pluginignore instead of splitting out a runtime/ directory. I'm leaning toward that direction for the long-term developer and third-party plugin experience, and I'd really like to hear your thoughts as the contributor who worked through the details here.

Could you share your view in #2966? In the meantime, please hold off on addressing the earlier runtime/ doc comments here so we don't ask you to do extra work before the direction is settled.


@Lumea-art 非常感谢你在这个 PR 上细致的改动,也看到核心 CI 都已经通过了。

合并之前,@jasper-yl 在 #2966 里提了一个替代方案:通过框架侧的 .pluginignore 解决,而不是拆分 runtime/ 子目录。从长期的本地开发体验和第三方插件复用角度,我比较倾向这个方向,但你是实际把整套流程跑通的贡献者,很想先听听你的看法。

方便的话欢迎在 #2966 里聊聊你的意见。在方向定下来之前,先不用针对刚才那几条 runtime/ 文档意见继续改了,避免白做重复工作。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:knowledge-base Primary module: knowledge base import, processing and retrieval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a source layout for first-party Server plugins and migrate knowledge-base

5 participants